package ceha.application;

import ceha.util.BackupMysql;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class CEHAAdmin extends javax.swing.JFrame {

    private CEHALogin main;

    public CEHAAdmin() {
        initComponents();
    }

    CEHAAdmin(CEHALogin main) {
        initComponents();
        this.main = main;
    }

    public String getMysqlField() {
        return MysqlField.getText();
    }

    public JCheckBox getCheckAuto() {
        return checkAuto;
    }

    public JPasswordField getPassAuto() {
        return passAuto;
    }

    public JTextField getPseudoAuto() {
        return pseudoAuto;
    }

    public JTextField getRepvignette() {
        return repvignette;
    }

    public JCheckBox getEcr17p() {
        return ecr17p;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        paramPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        repvignette = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        droitsButton = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        pseudoAuto = new javax.swing.JTextField();
        passAuto = new javax.swing.JPasswordField();
        jLabel7 = new javax.swing.JLabel();
        checkAuto = new javax.swing.JCheckBox();
        MysqlField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        lancerButton1 = new javax.swing.JButton();
        nomsave1 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        dossiersave1 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        parcourirButton = new javax.swing.JButton();
        ecr17p = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder1.setShadowColor(new java.awt.Color(255, 255, 204));
        paramPanel.setBorder(dropShadowBorder1);
        paramPanel.setFont(new java.awt.Font("Tahoma", 1, 11));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setForeground(new java.awt.Color(153, 0, 0));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Répertoire des vignettes");

        repvignette.setBackground(new java.awt.Color(255, 255, 204));
        repvignette.setFont(new java.awt.Font("Tahoma", 1, 14));
        repvignette.setText("C:\\Documents and Settings\\Gilles\\ImageCeha");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setForeground(new java.awt.Color(153, 0, 0));
        jLabel2.setText("Droits des membres");

        droitsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/gestion-droits.gif"))); // NOI18N
        droitsButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        droitsButton.setContentAreaFilled(false);
        droitsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                droitsButton(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(new java.awt.Color(153, 0, 0));
        jLabel5.setText("Login automatique");

        jLabel6.setBackground(new java.awt.Color(0, 0, 0));
        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Pseudo ");
        jLabel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel6.setOpaque(true);

        pseudoAuto.setBackground(new java.awt.Color(255, 255, 204));
        pseudoAuto.setFont(new java.awt.Font("Arial", 1, 12));
        pseudoAuto.setText("ceha");
        pseudoAuto.setToolTipText("");
        pseudoAuto.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 102, 255), new java.awt.Color(204, 255, 255), null, null));

        passAuto.setBackground(new java.awt.Color(255, 255, 204));
        passAuto.setFont(new java.awt.Font("Arial", 1, 12));
        passAuto.setText("ceha");
        passAuto.setToolTipText("laissez les champs vides pour une simple recherche");
        passAuto.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 51, 255), new java.awt.Color(204, 255, 255), null, null));

        jLabel7.setBackground(new java.awt.Color(0, 0, 0));
        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Mot de passe");
        jLabel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel7.setOpaque(true);

        checkAuto.setFont(new java.awt.Font("Tahoma", 1, 11));
        checkAuto.setSelected(true);
        checkAuto.setText("activer");

        MysqlField.setBackground(new java.awt.Color(255, 255, 204));
        MysqlField.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        MysqlField.setText("C:\\wamp\\wampmanager.exe");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel8.setForeground(new java.awt.Color(153, 0, 0));
        jLabel8.setText("Gestionnaire serveur MySql");

        lancerButton1.setBackground(new java.awt.Color(255, 255, 255));
        lancerButton1.setFont(new java.awt.Font("Arial", 1, 12));
        lancerButton1.setForeground(new java.awt.Color(153, 0, 51));
        lancerButton1.setText("Lancer la sauvegarde");
        lancerButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lancerButton1backupButton(evt);
            }
        });

        nomsave1.setFont(new java.awt.Font("Times New Roman", 1, 14));

        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabel9.setForeground(new java.awt.Color(153, 0, 0));
        jLabel9.setText("Nom de la sauvegarde");

        dossiersave1.setFont(new java.awt.Font("Times New Roman", 1, 14));

        jLabel10.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabel10.setForeground(new java.awt.Color(153, 0, 0));
        jLabel10.setText("Dossier de souvegarde (éventuellement externe)");

        parcourirButton.setFont(new java.awt.Font("Times New Roman", 1, 14));
        parcourirButton.setText("Choisir");
        parcourirButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parcourirButtonchoixRepA(evt);
            }
        });

        ecr17p.setBackground(new java.awt.Color(255, 255, 255));
        ecr17p.setFont(new java.awt.Font("Arial", 1, 12));
        ecr17p.setForeground(new java.awt.Color(153, 0, 51));
        ecr17p.setSelected(true);
        ecr17p.setText("écran 17 pouces");

        javax.swing.GroupLayout paramPanelLayout = new javax.swing.GroupLayout(paramPanel);
        paramPanel.setLayout(paramPanelLayout);
        paramPanelLayout.setHorizontalGroup(
            paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paramPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(checkAuto)
                    .addComponent(jLabel1)
                    .addComponent(jLabel8)
                    .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(MysqlField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(repvignette, javax.swing.GroupLayout.Alignment.LEADING))
                    .addGroup(paramPanelLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 211, Short.MAX_VALUE))
                    .addGroup(paramPanelLayout.createSequentialGroup()
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pseudoAuto, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                            .addComponent(passAuto, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                        .addGap(284, 284, 284)))
                .addGap(21, 21, 21))
            .addGroup(paramPanelLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ecr17p)
                    .addComponent(lancerButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel9)
                    .addGroup(paramPanelLayout.createSequentialGroup()
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(dossiersave1)
                            .addComponent(nomsave1, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(parcourirButton, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(paramPanelLayout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(droitsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        paramPanelLayout.setVerticalGroup(
            paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paramPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(repvignette, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(MysqlField, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(paramPanelLayout.createSequentialGroup()
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(checkAuto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(pseudoAuto, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(passAuto)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, paramPanelLayout.createSequentialGroup()
                        .addComponent(droitsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)))
                .addGroup(paramPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dossiersave1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(parcourirButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nomsave1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lancerButton1)
                .addGap(53, 53, 53)
                .addComponent(ecr17p)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 490, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(14, 14, 14)
                    .addComponent(paramPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 503, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(paramPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void droitsButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_droitsButton
        //        droitsUtilisateursJInternalFrame.setVisible(true);
}//GEN-LAST:event_droitsButton

    private void lancerButton1backupButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lancerButton1backupButton
        if (!nomsave1.getText().equals("")) {
            try {

                new BackupMysql(dossiersave1.getText() + nomsave1.getText() + ".zip");
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (Exception ex) {
                ex.printStackTrace();
            }

        }
}//GEN-LAST:event_lancerButton1backupButton

    private void parcourirButtonchoixRepA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parcourirButtonchoixRepA
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("choosertitle");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setAcceptAllFileFilterUsed(false);
        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            dossiersave1.setText(chooser.getCurrentDirectory().getAbsolutePath() + "\\");
        }
        //            System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
        //            System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
}//GEN-LAST:event_parcourirButtonchoixRepA
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField MysqlField;
    private javax.swing.JCheckBox checkAuto;
    private javax.swing.JTextField dossiersave1;
    private javax.swing.JButton droitsButton;
    private javax.swing.JCheckBox ecr17p;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JButton lancerButton1;
    private javax.swing.JTextField nomsave1;
    private javax.swing.JPanel paramPanel;
    private javax.swing.JButton parcourirButton;
    private javax.swing.JPasswordField passAuto;
    private javax.swing.JTextField pseudoAuto;
    private javax.swing.JTextField repvignette;
    // End of variables declaration//GEN-END:variables
}
